package com.amado.course36ByteStream;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class S08BufferInputStream {
	public static void main(String[] args) throws IOException {
		FileInputStream in = new FileInputStream("d:/123.txt");
		//每次从读取1024个字节，放入缓冲区 
		BufferedInputStream bin = new BufferedInputStream(in, 1024);
		byte[] data = new byte[10];
		//从缓冲区读取数据，如果缓存区已读取完，缓存区再从文件读取1024个字节
		int size = bin.read(data);
		while (size != -1) {
			System.out.println(new String(data));
			size = bin.read(data);
		}
		bin.close();
		in.close();
	}

}
